$OpenBSD: patch-src_pdfgrep_cc,v 1.2 2017/03/15 11:56:17 tb Exp $

disable locale::global(locale("")) to avoid a segfault in the UTF-8 locale.
--- src/pdfgrep.cc.orig	Sat Mar  4 09:11:53 2017
+++ src/pdfgrep.cc	Tue Mar 14 22:45:49 2017
@@ -423,12 +423,18 @@ static void handle_poppler_errors(const string &msg, v
 int main(int argc, char** argv)
 {
 	Options options;
+
+	if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
+		fprintf (stderr, "pdfgrep: pledge\n");
+		exit (1);
+	}
+
 	init_colors(options.outconf.colors);
 
 	// Set locale to user-preference. If this locale is an UTF-8 locale, the
 	// regex-functions regcomp/regexec become unicode aware, which means
 	// e.g. that '.' will match a unicode character, not a single byte.
-	locale::global(locale(""));
+	// locale::global(locale(""));
 
 	enum re_engine_type {
 		RE_POSIX = 0,
@@ -649,6 +655,11 @@ int main(int argc, char** argv)
 	bool color_tty = isatty(STDOUT_FILENO) && getenv("TERM") &&
 		strcmp(getenv("TERM"), "dumb");
 
+	if (pledge("stdio rpath wpath cpath", NULL) == -1) {
+		fprintf (stderr, "pdfgrep: pledge\n");
+		exit (1);
+	}
+
 	options.outconf.color =
 		use_colors == COLOR_ALWAYS
 		|| (use_colors == COLOR_AUTO && color_tty);
@@ -689,6 +700,12 @@ int main(int argc, char** argv)
 			char *limitstr = getenv("PDFGREP_CACHE_LIMIT");
 			unsigned int limit = limitstr ? strtoul(limitstr, NULL, 10) : 200;
 			limit_cachesize(options.cache_directory.c_str(), limit);
+		}
+	}
+	if (!options.use_cache) {
+		if (pledge("stdio rpath", NULL) == -1) {
+			fprintf (stderr, "pdfgrep: pledge\n");
+			exit (1);
 		}
 	}
 
